package com.nf;

import com.github.pagehelper.PageInfo;
import com.nf.dao.deptDao;
import com.nf.entity.deptEntity;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.List;

@SpringBootApplication
@MapperScan("com.nf.dao")
public class Ch04Application  {


    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(Ch04Application.class, args);
        deptDao bean = context.getBean(deptDao.class);
        //deptEntity byId = bean.getById();
       // System.out.println("byId = " + byId);

        int pageNum=2;
        int pageSize=3;
        List<deptEntity> all = bean.getAll(pageNum, pageSize);
        PageInfo<deptEntity> pageInfo = new PageInfo<>(all);
        System.out.println(pageInfo);
    }

//    @Autowired
//    private deptDao dao;
//
//    @Override
//    public void run(String... args) throws Exception {
//        deptEntity byId = dao.getById();
//        System.out.println("byId = " + byId);
//    }
//
//    @Override
//    public void run(ApplicationArguments args) throws Exception {
//
//    }
}
